- if can? current_user, :write_merge_request, @project
  = link_to new_project_merge_request_path(@project), class: "pull-right btn btn-new", title: "New Merge Request" do
    %i.icon-plus
    New Merge Request
%h3.page-title
  Merge Requests
  %span (#{@merge_requests.total_count})


.row
  .span3
    = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project)
  .span9
    .ui-box
      .title
        .mr-filters
          %span Filter by
          .dropdown.inline.prepend-left-10
            %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"}
              %i.icon-user
              %span.light assignee:
              - if @assignee.present?
                %strong= @assignee.name
              - elsif params[:assignee_id] == "0"
                Unassigned
              - else
                Any
              %b.caret
            %ul.dropdown-menu
              %li
                = link_to project_filter_path(assignee_id: nil) do
                  Any
                = link_to project_filter_path(assignee_id: 0) do
                  Unassigned
              - @project.team.members.sort_by(&:name).each do |user|
                %li
                  = link_to project_filter_path(assignee_id: user.id) do
                    = image_tag gravatar_icon(user.email), class: "avatar s16", alt: ''
                    = user.name

          .dropdown.inline.prepend-left-10
            %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"}
              %i.icon-time
              %span.light milestone:
              - if @milestone.present?
                %strong= @milestone.title
              - elsif params[:milestone_id] == "0"
                None (backlog)
              - else
                Any
              %b.caret
            %ul.dropdown-menu
              %li
                = link_to project_filter_path(milestone_id: nil) do
                  Any
                = link_to project_filter_path(milestone_id: 0) do
                  None (backlog)
              - project_active_milestones.each do |milestone|
                %li
                  = link_to project_filter_path(milestone_id: milestone.id) do
                    %strong= milestone.title
                    %small.light= milestone.expires_at

      %ul.well-list.mr-list
        = render @merge_requests
        - if @merge_requests.blank?
          %li
            %h4.nothing_here_message No merge requests to show
    - if @merge_requests.present?
      .pull-right
        %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter

      = paginate @merge_requests, theme: "gitlab"

:javascript
  $(merge_requestsPage);
